<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Page extends Model
{
    protected $fillable = [
        'user_id',
        'title',
        'slug',
        'content',
        'status',
        'template'
    ];
    
    public function user()
    {
        return $this->belongsTo(User::class);
    }
    
    // 作用域：仅获取已发布的页面
    public function scopePublished($query)
    {
        return $query->where('status', 'published');
    }
}
